package com.example.myerp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.myerp.mapper.S_cell_fp2Mapper;
import com.example.myerp.mapper.S_cell_fp3Mapper;
import com.example.myerp.pojo.S_cell;
import com.example.myerp.pojo.S_cell_fp;
import com.example.myerp.mapper.S_cell_fpMapper;
import com.example.myerp.pojo.S_cell_fp2;
import com.example.myerp.pojo.S_cell_fp3;
import com.example.myerp.service.S_cell_fpService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zhuxingyu
 * @since 2021-08-13
 */
@SuppressWarnings(value = "all")
@Service
public class S_cell_fpServiceImpl implements S_cell_fpService {

    @Autowired
    S_cell_fpMapper mapper;
    @Autowired
    S_cell_fp2Mapper mapper2;
    @Autowired
    S_cell_fp3Mapper mapper3;

    @Override
    public Integer Product_one_Add(String First_kind_id, String prename) {
        S_cell_fp s = new S_cell_fp();
        s.setFirstKindId(First_kind_id);
        s.setFirstKindName(prename);
        return mapper.insert(s);
    }

    @Override
    public Integer product_second_Add(String oneid, String second, String secondName) {
        S_cell_fp2 s = new S_cell_fp2(null, oneid, second, secondName, null);
        return mapper2.insert(s);
    }

    @Override
    public Integer product_second_Add2(S_cell_fp2 s) {
        UpdateWrapper<S_cell_fp2> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id", s.getId());
        S_cell_fp2 s_cell_fp21 = new S_cell_fp2();
        s_cell_fp21.setTwolevelarean(s.getTwolevelarean());
        s_cell_fp21.setFp_id(s.getFp_id());
        int update = mapper2.update(s_cell_fp21, updateWrapper);
        return update;

    }

    @Override
    public Integer product_three_Add(String threeId, String thirdproName, String twoId) {
        S_cell_fp3 s = new S_cell_fp3(null, threeId, thirdproName, twoId, null);
        return mapper3.insert(s);
    }

    @Override
    public IPage<S_cell_fp> getPageList(Long pageNum, Long pageSize) {
        Page<S_cell_fp> p = new Page<S_cell_fp>(pageNum, pageSize, true);
        return mapper.getPageList(p);
    }

    @Override
    public Integer uodateStoreId(Long storeId, Long id, String ilevelarean) {
        S_cell_fp s_cell_fp = new S_cell_fp();
        s_cell_fp.setIlevelarean(ilevelarean);
        s_cell_fp.setStoreId(storeId);
        UpdateWrapper<S_cell_fp> wrapper = new UpdateWrapper<S_cell_fp>();
        return mapper.update(s_cell_fp, wrapper.eq("id", id));
    }

    @Override
    public Integer insertadd(S_cell_fp s_cell_fp) {
        return mapper.insert(s_cell_fp);
    }

    @Override
    public Integer rowCount(S_cell_fp s_cell_fp) {
        return mapper.rowCount(s_cell_fp);
    }

    @Override
    public Long InterMaxId() {
        return mapper.InterMaxId();
    }

    @Override
    public IPage<S_cell_fp2> getfp2(Long pageNum, Long pageSize) {
        Page<S_cell_fp2> page = new Page<>(pageNum, pageSize, true);
        return mapper2.getfp2(page);
    }

    @Override
    public Integer product_second_Add2(S_cell_fp s_cell_fp) {
        return mapper.insert(s_cell_fp);
    }

    @Override
    public String ilevelarean(Integer firstKindId) {
        return mapper.ilevelarean(firstKindId);
    }

    @Override
    public List<S_cell_fp> getduiYing(String firstKindId) {
        return mapper.getduiYing(firstKindId);
    }


    @Override
    public Integer insertAddS_Cell_fp2(S_cell_fp2 s) {
        return mapper2.addfp2(s);
    }

    @Override
    public Integer s_Cell_fp2_Count(S_cell_fp2 s) {
        return mapper2.fp2_count(s);
    }

    @Override
    public Integer s_cell_fpCount(Long id) {
        QueryWrapper<S_cell_fp2> query = new QueryWrapper<>();
        query.eq("fp_id", id);
        Integer count = mapper2.selectCount(query);
        return count;
    }

    @Override
    public Integer delfp2(Long id) {
        return mapper.deleteById(id);
    }

    @Override
    public IPage<S_cell_fp3> getPage3(Long pageNum, Long pageSize) {
        Page<S_cell_fp3> page = new Page<>(pageNum, pageSize, true);
        return mapper3.getPage3(page);
    }

    @Override
    public List<S_cell_fp3> getHouName(String secondKindId) {
        return mapper3.getHouName(secondKindId);
    }

    @Override
    public Integer insertS_cell_fp3(S_cell_fp3 s_cell_fp3) {
        return mapper3.insertS_cell_fp3(s_cell_fp3);
    }

    @Override
    public void UpdateS_cell_fp3(S_cell_fp3 s) {
        mapper3.UpdateS_cell_fp3(s);
    }

    @Override
    public Integer s_cell_fp3Count(S_cell_fp3 s) {
        return mapper3.s_cell_fp3Count(s);
    }

    @Override
    public Integer dels_cell_fp3(Long fp2_id) {
        return mapper3.deleteById(fp2_id);
    }

    @Override
    public Integer selCountfp3(Long id) {
        QueryWrapper<S_cell_fp3> query = new QueryWrapper<>();
        query.eq("fp2_id", id);
        return mapper3.selectCount(query);
    }

    @Override
    public Integer delCount_fp2(Long id) {
        return mapper2.deleteById(id);
    }

    @Override
    public Integer checkKunCun(Integer firstKindId, Integer secondKindId, Integer thirdKindId) {
        return mapper.checkKunCun(firstKindId,secondKindId,thirdKindId);
    }



}
